<template>
    <view>
        <wd-icon name="photo" size="30px" @click="user_scan"></wd-icon>
    </view>
</template>

<script setup>
    import { scanCodeGetSN } from '@/utils/scanCodeGetSN';

    const user_scan = async () => {
        console.log('点击了扫码进入');
        // 调起条码扫描
        try {
            let sn = await scanCodeGetSN();
            console.log('sn:', sn);
            uni.setStorageSync('user', { machineSn: sn });
            uni.switchTab({
                url: '/pages/custom/index/index'
            });
        } catch (error) {
            uni.showToast({
                title: '识别失败',
                icon: 'none'
            });
        }
    };
</script>

<style lang="scss" scoped></style>